<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    //数组会继承与Array，所以再Array得prototype上面添加方法就可以像push方法一样调用
    Array.prototype.myPush = function(...args)
    {
        for(let i = 0;i<args.length;i++)
        {
            this[this.length] = args[i];
        }
        return this.length;
    }

    let arr = [1];
    arr.myPush(12)
    arr.myPush(10,20,30,10);
    console.log(arr);
</script>
<body>
    
</body>
</html>